package com.topisv.tms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.topisv.tms.entity.StoragePipe;
import com.topisv.tms.repository.StoragePipeDao;

//Spring Bean的标识.
@Component
//默认将类中的所有public函数纳入事务管理.
@Transactional(readOnly = true)
public class StoragePipeService {
	private StoragePipeDao storagePipeDao;
	
	@Autowired
	public void setStoragePipeDao(StoragePipeDao storagePipeDao) {
		this.storagePipeDao = storagePipeDao;
	}

	
	public StoragePipe getStoragePipe(Long id) {
		return storagePipeDao.findOne(id);
	}
	
	public List<StoragePipe> findBySPCode(String sp_code) {
		return storagePipeDao.findBySPCode(sp_code);
	}
	
	@Transactional(readOnly = false)
	public void saveStoragePipe(StoragePipe entity) {
		storagePipeDao.save(entity);
	}
	
	@Transactional(readOnly = false)
	public void deleteStoragePipe(Long id) {
		storagePipeDao.delete(id);
	}
	
	public List<StoragePipe> getAllStoragePipe() {
		return (List<StoragePipe>) storagePipeDao.findAll();
	}
	
}
